﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class cms_profile : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        pnlReadOnly.Visible = true;
        pnlEdit.Visible = false;
        if (!IsPostBack)
            this.LoadProfile();
    }
    private void LoadProfile()
    {
        txtFName.Text = Profile.FirstName;
        txtFNameEdit.Text = Profile.FirstName;
        txtLName.Text = Profile.LastName;
        txtLNameEdit.Text = Profile.LastName;
        txtGender.Text = Profile.Gender ? "Nam" : "Nữ";
        rbtMan.Checked = Profile.Gender ? true : false;
        txtAddress.Text = Profile.Address;
        txtAddressEdit.Text = Profile.Address;
        txtEmail.Text = Profile.Email;
        txtEmailEdit.Text = Profile.Email;
        txtPhone.Text = Profile.PhoneNumber;
        txtPhoneEdit.Text = Profile.PhoneNumber;
    }
    protected void btnEdit_Click(object sender, EventArgs e)
    {
        pnlReadOnly.Visible = false;
        pnlEdit.Visible = true;
    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        pnlReadOnly.Visible = true;
        pnlEdit.Visible = false;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (!Page.IsValid) return;
        Profile.FirstName = txtFNameEdit.Text;
        Profile.LastName = txtLNameEdit.Text;
        Profile.Gender = rbtMan.Checked ? true : false;
        Profile.Address = txtAddressEdit.Text;
        Profile.Email = txtEmailEdit.Text;
        Profile.PhoneNumber = txtPhoneEdit.Text;
        Response.Redirect("profile.aspx");
    }
}
